<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			div{
				width: 100px;
				height: 100px;
				background: red;
			}
		</style>
	</head>
	<body>
<!-- 		<button id="btn">隐藏</button>
		<button id="btn2">显示</button> -->
		
		<button id="btn">切换</button>
		<div id="box"></div>
		<!-- js 代码 -->
		<script>
			let oBtn = document.getElementById('btn');
			let oBox = document.getElementById('box');
			let onOff = true;
			oBtn.onclick = function(){
				if(onOff){
					oBox.style.display = 'none';	
				}else{
					oBox.style.display = 'block';
				}
				onOff = !onOff;
			}
					
		</script>
	</body>
</html>
